﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using RoadTeam.Model;
using RoadTeam.Enums;
using RoadTeam.SysInterface;

namespace RoadTeam.BLL
{
    public class CsValidateRoomBll : BllBase
    {

        public static DataTable GetEmptyTable()
        {
            SqlWhere where = new SqlWhere();
            where.Info = new Model.CsValidateRoom() { ValidateRoomIdentifier = "-1" };
            return CsValidateRoom.Select(where, GlobalConfig.ConnectionString);
        }


        public void insert(DataTable dt_ValidateRoom)
        {
            DataTable dt_RtValidateRoom = FactoryClass.CreateCsValidateRoom().GetEmptyTable();
            DataRow dr_RtValidateRoom;
            foreach (DataRow dr in dt_ValidateRoom.Rows)
            {
                //ValidateRoomCode,FoundDate,ValidateStaffID,DeveloperOpinion
                //,SubjoinExplain,AuditingState,ValidateRoomState,UnitID,OrganID,App_Identifier
                dr_RtValidateRoom = dt_RtValidateRoom.NewRow();
                dr_RtValidateRoom[0] = dr["ValidateRoomCode"];
                dr_RtValidateRoom[1] = dr["FoundDate"];
                dr_RtValidateRoom[2] = FactoryClass.CreateSmStaff().GetStaffID(dr["ValidateStaffIdentifier"].ToString());
                dr_RtValidateRoom[3] = dr["DeveloperOpinion"];
                dr_RtValidateRoom[4] = dr["SubjoinExplain"];
                //dr_RtValidateRoom[5] = dr["AuditingState"];
                dr_RtValidateRoom[5] = dr["ValidateRoomState"];
                dr_RtValidateRoom[6] = FactoryClass.CreateRmUnit().GetUnitID(dr["UnitIdentifier"].ToString());
                    //根据单元唯一标识获取单元ID
                dr_RtValidateRoom[7] = FactoryClass.CreateSmOrgan().GetOraganID(dr["OrganIdentifier"].ToString());
                    //根据机构唯一标识获取机构ID
                dr_RtValidateRoom[8] = dr["ValidateRoomIdentifier"];
                dt_RtValidateRoom.Rows.Add(dr_RtValidateRoom);
            }
            FactoryClass.CreateCsValidateRoom().Insert(dt_RtValidateRoom);
            CsValidateRoom.InsertDatatable(dt_ValidateRoom, GlobalConfig.ConnectionString);
        }
    }
}
